<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;

use App\Http\Requests;
use App\Http\Controllers\Controller;
use View,DB,Auth;

class UserController extends Controller
{
    #Todo
    public function edit()
    {
        return View::make('user.edit');
    }

    public function show()
    {
    	$user = Auth::user();
    	return View::make('user.user')->with(['user' => $user]);
    }

    public function update()
    {

    }

    public function uploadimage(Request $requests)
    {
    	if($requests->hasFile('file')){
    		$filename = 'u_'.Auth::user()->id.uniqid(Auth::user()->id).'.'.$requests->file('file')->getClientOriginalExtension();
    		$requests->file('file')->move(public_path('/user/img/'), $filename);
    		DB::table('users')
    					->where('id', Auth::user()->id)
    					->update(['img'=>$filename]);
    	}
    }

    #Todo
    public function userHome(Request $requests)
    {
        $id = (int)trim($requests->input('id'));
        $info = ['score'=>99, 'caller'=>'老二', 'zuopin'=>['sad movie','ba jun tu','mingyunjiaoxiangqu']];
        return View::make('user.home')->with(['info'=>$info]);
    }

    //find same intrest
    public function findSameIntrest(Request $requests)
    {
        //have a table,saved users views history,select this table to find some same like users
        //table 
    }
}
